package com.itheima.polymorphic;

public class Demo1Polymorphic {
    public static void main(String[] args) {
        Animal a1 = new Dog();
        Animal a2 = new Cat();
        a1.eat();
        a2.eat();
    }
    public void useAnimal(Animal a){
        a.eat();
    }
}
abstract class Animal{
    abstract void eat();
}
class Dog extends Animal{
    @Override
    public void eat(){
        System.out.println("狗吃肉");
    }
}
class Cat extends Animal{
    @Override
    public void eat(){
        System.out.println("猫吃鱼");
    }
}